package com.tuyou.springboot.redis;

import com.tuyou.springboot.comon.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis/")
public class RedisController {

    @Autowired
    UserRedisRepository userRedisRepository;

    @PostMapping("/")
    public User set() {
        User user = new User(1,"tuyou", (short)30);
        userRedisRepository.save(user);
        userRedisRepository.stringRedisTemplateDemo();
        return user;
    }

    @GetMapping("/getStr")
    public String getStr() {
        return userRedisRepository.getString();
    }

    @GetMapping("/getUser")
    public User getUser() {
        return userRedisRepository.getUser();
    }
}
